﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Data;

public partial class per_documentary_me : MpageBase
{
    protected int m = ReadRequest.RequestInt("m");
    protected Model.UsersAccount user_account = null;
    protected Model.CMember CMember = null;
    protected List<Model.LotteryChipped> buyInfo = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind(); bindData();
        }
    }
    protected void Bind()
    {
        if (loginUserInfo != null && loginUserInfo.Id > 0)
        {
            user_account = BLL.UsersAccount.GetModelByuser_id(loginUserInfo.Id);
            CMember = BLL.CMember.GetModel(loginUserInfo.Id);
            if (user_account == null)
            {
                BLL.Session.Remove(BLL.CMember.LoginUserSessionKey);
                Response.Redirect("/default.aspx");
            }
        }
        else
        {
            Response.Redirect("/default.aspx");
        }
    }

    protected void bindData()
    {
        Bind();
        PagedDataSource pds = new PagedDataSource();
        string sql = "";
        sql = " UserID=" + loginUserInfo.Id;  
        int totalCount = 0;
        buyInfo = BLL.LotteryChipped.GetPageListBysql(this.AspNetPager1.CurrentPageIndex - 1, this.AspNetPager1.PageSize, sql, out totalCount);
        if (buyInfo != null && buyInfo.Count > 0)
        {
            AspNetPager1.Visible = true;
            AspNetPager1.RecordCount = totalCount;
            pds.AllowPaging = true;
            pds.PageSize = AspNetPager1.PageSize;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;

        }
        else
        {
            AspNetPager1.Visible = false;
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        Bind();
        bindData();
    }
    public int getUserCount(int id)
    {
        DataTable dt = BLL.LotteryChippedUser.GetPageListBysql(" SELECT *  FROM LotteryChippedUser where  LotteryChippedID='" + id + "'");
       return dt.Rows.Count;
    }
}